package com.emeth.generation
{
	import com.emeth.air.FileUtils;
	
	import flash.filesystem.File;
	
	import mx.utils.ObjectUtil;

	public class TemplateManager
	{
		private static var instance:TemplateManager;
		
		private var _PMVC_BaseVO 						:	 String;
		private var _PMVC_AMFVO 						:	 String;
		private var _PMVC_XMLVO 						:	 String;

		private var _PMVC_ServiceDelegate 				:	 String;
		private var _PMVC_Collection 					:	 String;
		private var _PMVC_AMFService 					:	 String;
		private var _PMVC_AMFServiceRemoteProxy 		:	 String;
		
		// Tests
		private var _PMVC_TestCase						:	 String;
		private var _PMVC_TestSuite				 		:	 String;
		
		// HTML (copy for GAIA)
		private var _GAIA_HTML					 		:	 String;
		
		private const TEMPLATE_FOLDER 	: String	=  'assets/templates/';
		
		public function TemplateManager()
		{
			_PMVC_BaseVO					=	 getTemplate( TEMPLATE_FOLDER + 'BaseVO.txt' );
			_PMVC_AMFVO 						=	 getTemplate( TEMPLATE_FOLDER + 'AMFVO.txt' );
			_PMVC_XMLVO 						=	 getTemplate( TEMPLATE_FOLDER + 'XMLVO.txt' );
			
			_PMVC_ServiceDelegate 			=	 getTemplate( TEMPLATE_FOLDER + 'ServiceDelegate.txt' );
			_PMVC_Collection				=	 getTemplate( TEMPLATE_FOLDER + 'Collection.txt' );
			
			_PMVC_AMFService				=	 getTemplate( TEMPLATE_FOLDER + 'AMFService.class.php' );
			_PMVC_AMFServiceRemoteProxy		=	 getTemplate( TEMPLATE_FOLDER + 'ServiceRemoteProxy.txt' );
			
			_PMVC_TestCase					=	 getTemplate( TEMPLATE_FOLDER + 'TestCase.txt' );
			_PMVC_TestSuite					=	 getTemplate( TEMPLATE_FOLDER + 'TestSuite.xml' );
			
			_GAIA_HTML						=	 getTemplate( TEMPLATE_FOLDER + 'HTML.txt' );
		}
		
		public static function getInstance( ):TemplateManager
		{
			if( instance == null ) instance = new TemplateManager( );
			return instance;
		}
		
		private function getTemplate( fileURI : String ): String {
			return FileUtils.getFileString(File.applicationDirectory.resolvePath(fileURI));
		}

		public function get PMVC_AMFVO():String
		{
			return String( ObjectUtil.copy( _PMVC_AMFVO ) );
		}

		public function set PMVC_AMFVO(value:String):void
		{
			_PMVC_AMFVO = value;
		}

		public function get PMVC_ServiceDelegate():String
		{
			return String( ObjectUtil.copy( _PMVC_ServiceDelegate ) );
		}

		public function set PMVC_ServiceDelegate(value:String):void
		{
			_PMVC_ServiceDelegate = value;
		}

		public function get PMVC_Collection():String
		{
			return String( ObjectUtil.copy( _PMVC_Collection ) );
		}

		public function set PMVC_Collection(value:String):void
		{
			_PMVC_Collection = value;
		}

		public function get PMVC_BaseVO():String
		{
			return String( ObjectUtil.copy( _PMVC_BaseVO ) );
		}

		public function set PMVC_BaseVO(value:String):void
		{
			_PMVC_BaseVO = value;
		}

		public function get PMVC_AMFService():String
		{
			return String( ObjectUtil.copy( _PMVC_AMFService ) );
		}

		public function set PMVC_AMFService(value:String):void
		{
			_PMVC_AMFService = value;
		}

		public function get PMVC_AMFServiceRemoteProxy():String
		{
			return String( ObjectUtil.copy( _PMVC_AMFServiceRemoteProxy ) );
		}

		public function set PMVC_AMFServiceRemoteProxy(value:String):void
		{
			_PMVC_AMFServiceRemoteProxy = value;
		}

		public function get PMVC_TestCase():String
		{
			return String( ObjectUtil.copy( _PMVC_TestCase ) );
		}

		public function set PMVC_TestCase(value:String):void
		{
			_PMVC_TestCase = value;
		}

		public function get PMVC_TestSuite():String
		{
			return String( ObjectUtil.copy( _PMVC_TestSuite ) );
		}

		public function set PMVC_TestSuite(value:String):void
		{
			_PMVC_TestSuite = value;
		}

		public function get GAIA_HTML():String
		{
			return String( ObjectUtil.copy( _GAIA_HTML ) );
		}

		public function set GAIA_HTML(value:String):void
		{
			_GAIA_HTML = value;
		}

		public function get PMVC_XMLVO():String
		{
			return String( ObjectUtil.copy( _PMVC_XMLVO ) );
		}

		public function set PMVC_XMLVO(value:String):void
		{
			_PMVC_XMLVO = value;
		}


	}
}